Class yassl.javaproc
All Packages    This Package    Previous    Next

Class yassl.javaproc

java.lang.Object
   |
   +----yassl.pnode
           |
           +----yassl.javaproc

public class javaproc
extends pnode
This is the common interface to methods added from java classes.

New functions callable from yassl are created by subclassing javaproc and implementing the abstract apply method, and simply placing the new class along with the other support classes.

Here is an example of creating a procedure puts in yassl, which takes a string as its only argument and writing it through System.out.println.

public class yasslProcputs extends javaproc
{
  public pnode apply(pnode args[]) throws yasslError
  {
    if (args.length != 1)
      { throw new yasslError("puts expects 1 argument", this); }
    pnode s = actuals[0];
    if (!(s instanceof stringnode))
      { throw new yasslError("puts expects arg #1 to be a string", this); }
    System.out.println(((stringnode)s).val);
    return (parser.NULL);
  }
}
It should be properly subclassed from lambdanode, but done this way to save unnecessary space and work. Fix this? ;-)

Variable Index

 o saved_env
This keeps around the environment when the lambdanode was created.

Constructor Index

 o javaproc()
Create a wrapper around methods from java

Method Index

 o apply(pnode[])
apply the arguments to this procedure.
 o eval(Env)
Evaluation of a lambda node saves the environment as part of the object, and returns a copy of the object.
 o help(Env)
Override this to get help about new functions.

Variables

 o saved_env
  public Env saved_env
This keeps around the environment when the lambdanode was created.

Constructors

 o javaproc
  public javaproc()
Create a wrapper around methods from java

Methods

 o eval
  public final pnode eval(Env e)
Evaluation of a lambda node saves the environment as part of the object, and returns a copy of the object.
Overrides:
eval in class pnode

 o apply

  public abstract pnode apply(pnode actuals[]) throws yasslError
apply the arguments to this procedure. The enclosing environment is available in saved_env.

 o help

  public String help(Env e)
Override this to get help about new functions. The environment in which the help is called is passed in, in case you need to look up anything.
Overrides:
help in class pnode


All Packages    This Package    Previous    Next